CC = gcc
CFLAGS = -g -O2

all: dht-get dht-put dht-rm dht_node hashtbl dht-ping dht-kill dht-node-finger dht-node-ls

dht-get : dht-get.o
	$(CC) dht-get.c $(CFLAGS) -o dht-get

dht-put : dht-put.o
	$(CC) dht-put.c $(CFLAGS) -o dht-put

dht-rm : dht-rm.o
	$(CC) dht-rm.c $(CFLAGS) -o dht-rm

dht-put.o: dht-put.c dht.h
	$(CC) dht-put.c $(CFLAGS) -c 

dht-get.o: dht-get.c dht.h
	$(CC) dht-get.c $(CFLAGS) -c 

dht-rm.o: dht-rm.c dht.h
	$(CC) dht-rm.c $(CFLAGS) -c

dht-ping : dht-ping.o
	$(CC) dht-ping.c $(CFLAGS) -o dht-ping

dht-ping.o: dht-ping.c dht.h
	$(CC) dht-ping.c $(CFLAGS) -c 

dht-kill : dht-kill.o
	$(CC) dht-kill.c $(CFLAGS) -o dht-kill

dht-kill.o: dht-kill.c dht.h
	$(CC) dht-kill.c $(CFLAGS) -c 

dht-node-finger : dht-node-finger.o
	$(CC) dht-node-finger.c $(CFLAGS) -o dht-node-finger

dht-node-finger.o: dht-node-finger.c dht.h
	$(CC) dht-node-finger.c $(CFLAGS) -c 

dht-node-ls.o: dht-node-ls.c dht.h
	$(CC) dht-node-ls.c $(CFLAGS) -c 

dht-node-ls : dht-node-ls.o
	$(CC) dht-node-ls.c $(CFLAGS) -o dht-node-ls

hashtbl: hashtbl.o dht_node.o 
	cc -o hashtbl -g hashtbl.o dht_node.o -lcrypto

hashtbl.o: hashtbl.c hashtbl.h
	cc -o hashtbl.o -g -c hashtbl.c

dht_node : dht_node.o
	$(CC) dht_node.c hashtbl.c  $(CFLAGS) -o dht_node -lcrypto

dht_node.o: dht_node.c hashtbl.h
	cc -o dht_node.o -g -c dht_node.c 

clean:
	@rm -rf *.o dht-get dht-rm dht-put dht_node hashtbl dht-ping dht-kill dht-node-finger dht-node-ls *.dSYM

